home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / NewsFlash - Issue 03 (1989)(UGA - 17-Bit Software)[a].zip / NewsFlash - Issue 03 (1989)(UGA - 17-Bit Software)[a].adf / doc / loader.doc < prev    next >
Text File  |  1988-01-19  |  5KB  |  104 lines

  1. Libraries
  2. by ROGER from VIRUS.
  3. The source-file that I'll be explaining about is the simplified loader
  4. from my startupcoder. It's function is simple and so is the source.
  5. The source opends the dos.library,then it runs the execute command
  6. (don't mix it up with your CLI execute command),that
  7. will load/run the files mentioned at the 'command1' label,then the
  8. dos.library is closed and thats all.Extremely simple.This source just
  9. shows the usage of the 'openlibrary' command and how you should use
  10. library commands from assembler.Many people who just started assembler
  11. seem to have many problems in opening & using libraries.
  12. A library is nothing more than a bunch of routines in your ROM
  13. that make life easier (sometimes).One of these libraries is the Dos.library
  14. this library contains all the thing you need to handle the DOS.
  15. The source shows how powerfull one library command can be.The execute
  16. command needs some info before you use it.
  17.     D1    the adress of the command(s) that you wish to execute
  18.     D2    Filehandle of window for extra data,usualy 0
  19.     D3    Windowhandle,can be achieved by opening a dos window
  20.         if you want to execute in the standard CLI window
  21.         then this is 0
  22.     A6    Dosbase,standard when calling a Dos.library command.
  23.         The dosbase is saved in D0 when you open a library.
  24.         Then it's stored in a longword (8 bytes) with the label
  25.         'Dosbase'.
  26. But before you can use the execute command you must open the dos.library.
  27. This can be done with the Openlibrary command that can be found in the
  28. Exec.library.To use a library command you must know the base of the
  29. library.The execbase is always 4 (At the top of the source you can find
  30. 'Execbase = 4' -this is to make your life easier.The Amiga knows 
  31. thousands of these prefix numbers).
  32. The Openlibrary command must also have a pointer at the name of the library
  33. ,simply move 'Dosname' to A1 and make a label called Dosname: and
  34. Dc.b    "Dos.library" (this puts the data Dos.library at the label 'dosname'
  35. in your memory).
  36. Then do  'jsr openlibrary(a6)'.Again,at the top of the source is 
  37. 'Openlibrary =  -408' for your convenience.
  38. I know this all sounds pretty complicated when you're just starting,but
  39. once you'll get used to the libraries,they work really well.
  40. One thing about the 'Command1' label where the commands are listed:
  41. In the startupcoder the files will be loaded automaticly.In the
  42. source,you get the honour of naming the files...
  43. If you want to load/run more than one file,simply do this:
  44. Command1:
  45.         dc.b    "intro",$0a        ;$0a means RETURN
  46.         dc.b    "stack 50000",$0a
  47.         dc.b    "show picture",$0a
  48.         dc.b    00            ;00 is end of commands
  49.  
  50. Now let's look at the start of the source:
  51. ----------------------------------------------
  52. Opendoslibrary:
  53.         move.l     execbase,a6
  54.         lea    dosname,a1
  55.         jsr    openlib(a6)
  56.         move.l  d0,dosbase    
  57. ----------------------------------------------
  58. This opens the dos.library.
  59. In the dos-library at offset -222 is the execute-command.
  60. The Dos-Execute command loads and executes files
  61. ----------------------------------------------
  62. executer:    move.l    #command1,d1        ;move command in d1
  63.         move.l    dosbase,a6        ;dosbase in  a6
  64.         clr.l    d2            ;no external control
  65.         move.l    windowhd,d3        ;window to execute in;CLI
  66.         jsr    execute(a6)        ;And execute it.
  67. ----------------------------------------------
  68. The execute command needs the RUN command in the C-directory.
  69. The following routine closes the Dos.library again
  70. and gets you right back to where you started from...
  71. ----------------------------------------------
  72. Closelibrary:    move.l    execbase,a6
  73.         move.l    dosbase,a1
  74.         jsr    closelib(a6)
  75.         rts
  76. ----------------------------------------------
  77. This is the place where you store your command(s),
  78. or a startup-sequence for that matter.
  79. ----------------------------------------------
  80. Command1:
  81.     dc.b    "intro",00
  82.     even            ;Words at odd adresses are not allowed!
  83.  
  84. ----------------------------------------------
  85. dosname:    dc.b"dos.library",0          ;Name of library to be opened
  86. even
  87. ----------------------------------------------
  88. dosbase:    dc.l 0                  ;The base of the library
  89. even
  90. ----------------------------------------------
  91. windowhd:    dc.l 0                  ;This is 0-CLI window
  92. even
  93. ----------------------------------------------
  94.  
  95. The execute command is quite nice if you want to load programs.
  96. A loader for a bootmenu can be made in this way.Just put a code
  97. in the memory when you exit the bootmenu,make a routine in the loader 
  98. that puts different commands in d1,do the execute stuff,and ready is
  99. your loader....
  100.  
  101. That's all for now....
  102.  
  103. ROGER from VIRUS
  104.